<template>
	<view>
		<view class="cake-item" @click="handleDetail">
			<view>
				<image class="poster" :src="gdata.img" mode=""></image>
			</view>
			<view class="info-cont">
				<view class="info flex align-center justify-between">
					<view class="">
						<view class="fs-28">
							{{gdata.name}}
						</view>
						<view class="fs-16">
							{{gdata.french}}
						</view>
					</view>
					<view @click.stop="handleCartAdd" class="cart-btn margin-right-sm flex align-center justify-center">
						<text class="iconfont icon-daishouhuo"></text>
					</view>
				</view>
				<view class="fs-18">
					<text class="fs-14">￥</text>
					{{gdata.price}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "good-item",
		props:['gdata'],
		data() {
			return {

			};
		},
		methods:{
			handleDetail(){
				//点击跳转前先存储数据
				uni.setStorage({
					key:'detail',
					data:this.gdata,
					//success:保证存入成功之后在跳转
					success: () => {
						uni.navigateTo({
							url:'/pages/detail/detail'
						})
					}
				})
				
			},
			handleCartAdd(){
				this.$store.commit('cart/cartAddMut',{
					...this.gdata,
					indx:0
				})
			}
		}
	}
</script>

<style lang="scss">
	.cake-item {
		// display: flex;
		width: 350upx;
	
	.poster {
			height: 350upx;
			background-color: gray;
		}

		.fs-28 {
			margin-top: 24upx;
		}

		.fs-16 {
			margin: 14upx 0;
		}

		.fs-18 {
			margin-bottom: 22upx;
		}

		.cart-btn {
			width: 60upx;
			height: 60upx;
			border-radius: 50%;
			background-color: yellow;
		}
	}

</style>
